package web.servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import main.TankSicherheit;

/**
 * Servlet implementation class ReceiveCWFromFC
 */
public class ReceiveCWFromFC extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ReceiveCWFromFC() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.sendError(404);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		TankSicherheit.LOGGER.debug("ReceiveCWFromFCServlet: POST");
		Object o =  request.getSession().getAttribute("USERID");
		int id;
		if(o==null)
		{
			id=2;
		}
		else
		{
			id = (int)o;
		}
		if(TankSicherheit.isPermitted(id, "channelid"))
		{
			System.out.println(request.getParameter("channelid"));
			TankSicherheit.tankSicherheit.clanwarLineupReceiver.processHTTPPost(id,request.getParameterMap());
			response.setStatus(200);
		}
		else
		{
			TankSicherheit.LOGGER.debug("ReceiveCWFromFCServlet: no permission");
			response.sendError(403, "no permission");
		}

	}

}
